package com.hex.ds.hdtp.core.app.data.transfer.dto.request;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.util.Arrays;
import java.util.List;

/**
 * @Package: com.hex.ds.hdtp.core.inf.data.transfer.po
 * @ClassName DataTransferTaskPo
 * @Description: 数据迁移任务-RequestDto对象
 * @Author: wz.li
 * @Date 2023/8/17 16:44
 * @Version v2.0.2
 **/
@Data
public class DataTransferTaskRequestDto {

    private String pkId;

    private String taskName;

    private String dataSyncType;

    private String dataSyncStartTime;

    private String dataSyncEndTime;

    private String status;

    private Integer total;

    private Integer successCount;

    private Integer failCount;

    private String isDataAnalysis;

    private String startTime;

    private String endTime;

    private List<DataTransferListRequestDto> tableList;

    private String dataTransferType;

    private String transferType;

    public boolean isDataAnalysis(){
        return "Y".equals(isDataAnalysis);
    }

    public List<DateTime> getBizDateList() {
        if (dataSyncType.equals("TODAY")) {
            return Arrays.asList(DateUtil.date());
        } else if (dataSyncType.equals("YESTERDAY")) {
            return Arrays.asList(DateUtil.yesterday());
        } else if (dataSyncType.equals("DAY_LAST_MONTH")) {
            return Arrays.asList( DateUtil.endOfMonth(DateUtil.date()));
        } else {
            return DateUtil.rangeToList(DateUtil.parse(dataSyncStartTime), DateUtil.parse(dataSyncEndTime), DateField.DAY_OF_YEAR);
        }
    }

}
